package de.lulusoft.anothertorrent.gui.perspectives;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

import de.lulusoft.anothertorrent.gui.views.ConsoleView;
import de.lulusoft.anothertorrent.gui.views.OverviewView;
import de.lulusoft.anothertorrent.gui.views.ServerView;
import de.lulusoft.anothertorrent.gui.views.TorrentDetailsView;
import de.lulusoft.anothertorrent.gui.views.TorrentListView;

public class AnotherTorrentPerspective implements IPerspectiveFactory {
	
	public static final String ID = "de.lulusoft.anothertorrent.gui.perspectives.AnotherTorrentPerspective";
	
	public static final String FOLDER_CONNECTED_ID = "FOLDER_CONNECTED";
	public static final String FOLDER_TORRENTLISTS_ID = "FOLDER_TORRENTLISTS";
	public static final String FOLDER_TORRENTDETAILS_ID = "FOLDER_TORRENTDETAILS";
	public static final String FOLDER_SERVER_ID = "FOLDER_SERVER";
	
	private IFolderLayout connected = null;
	private IFolderLayout details = null;
	private IFolderLayout main = null;
	private IFolderLayout server = null;

	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();
		layout.setEditorAreaVisible(false);
		layout.setFixed(false);
		
		server = layout.createFolder(FOLDER_SERVER_ID, IPageLayout.LEFT, 0.2f, editorArea);
		connected = layout.createFolder(FOLDER_CONNECTED_ID, IPageLayout.BOTTOM, 0.3f, FOLDER_SERVER_ID);
		details = layout.createFolder(FOLDER_TORRENTDETAILS_ID, IPageLayout.BOTTOM, 0.7f, editorArea);
		main = layout.createFolder(FOLDER_TORRENTLISTS_ID, IPageLayout.TOP, 0.3f, editorArea);
		
		server.addView(ServerView.ID);
		connected.addPlaceholder(OverviewView.ID + ":*");	
		details.addPlaceholder(TorrentDetailsView.ID + ":*");
		details.addPlaceholder(ConsoleView.ID + ":*");
		main.addPlaceholder(TorrentListView.ID + ":*");
		
		// Permit closable on some views
		layout.getViewLayout(ServerView.ID).setCloseable(false);
		layout.getViewLayout(ServerView.ID).setMoveable(false);

	}

}
